import java.io.IOException;

public class DayOfWeek {
	enum WeekDays {
		Sunday, Monday, Tuesday, Wednesday, Thurthday, Friday, Saturday,

	}

	enum Month {
		JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER;

		static int getMonth(String s) {
			return Month.valueOf(s.toUpperCase()).ordinal() + 1;
		}
	}

	private int day;
	private int month;
	private int year;

	public DayOfWeek(int day, int month, int year) {
		this.day = day;
		this.month = month;
		this.year = year;
	}

	public static void main(String[] args) throws NumberFormatException, IllegalArgumentException, IOException  {
	
		DayOfWeek date = getUserData(Input.parse("Input date in format 'dd <Month> yyyy' [example - 12 October 2011])"));
		System.out.println("Its " + getWeekDayName(date));
	
	}

	public static DayOfWeek getUserData(String[] inputedStringArray) {
		int month = Month.getMonth(inputedStringArray[1]);
		int day = (int) Integer.valueOf(inputedStringArray[0]);
		int year = (int) Integer.valueOf(inputedStringArray[2]);

		return new DayOfWeek(day, month, year);
	}

	private static WeekDays getWeekDayName(DayOfWeek date) {
		return WeekDays.values()[getWeekdayIndex(date.day, date.month,date.year)];
	} 
	
	public static int getWeekdayIndex(int day, int month, int year) {
		final int WEEKDAYS_NUMBER = 7;
		final int[] WEEKDAY_MONTHLY_SHIFT = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2,
				4 };

		year = (month < 3) ? year-- : year; // shift for a case when year is leap and the month is January or February

		int leapYearsAdditions = year / 4 + year / 400 - year / 100;

		return (year + leapYearsAdditions + WEEKDAY_MONTHLY_SHIFT[month - 1] + day)
				% WEEKDAYS_NUMBER;
	}

}
